//角色管理相关的接口函数
//导入二次封装axios
import request from "@/utils/request";
import type { LoginRes, GetUserInfoRes } from "./models/loginModel";

//枚举接口地址
enum Api {
  loginUrl = "/admin/acl/index/login",
  logoutUrl = "/admin/acl/index/logout",
  getUserInfoUrl = "/admin/acl/index/info",
}

/**
 * 登录
 * @param username
 * @param password
 * @returns  LoginRes
 */
export const loginApi = (username: string, password: string) => {
  return request.post<any, LoginRes>(Api.loginUrl, {
    username,
    password,
  });
};

/**
 * 退出登录
 * @returns null
 */
export const logoutApi = () => {
  return request.post<any, null>(Api.logoutUrl);
};

/**
 * 获取用户信息
 * @returns GetUserInfoRes
 */
export const getUserInfoApi = () => {
  return request.get<any, GetUserInfoRes>(Api.getUserInfoUrl);
};
